# -*- coding: utf-8 -*-
import numpy as np

average= np.array([[ 0.10359571 ,0.2752874 ,  0.22804961 , 0.19473572 ],
 [ 0.01298461 , 0.24923545,  0.13033225 , 0.23017796],
 [ 0.0696816   ,0.16091577 , 0.08600108 , 0.20998663],
 [ 0.34177799 , 0.0739792  , 0.10555651 , 0.09860293],
 [ 0.024412   , 0.32836651 , 0.2558006  , 0.14568211],
 [ 0.13649001 , 0.17380795 , 0.02806738 , 0.29422387]])

def calculate_deviation(data, average):
    iLenData = average.shape   #iLen[0]:Line; iLen[1]:Row
    i = 0   #Line
    
    iLenAve = average.shape
    
    dist = np.array([])
    
    while i < iLenData[0]:
        temp = np.linalg.norm(data - average[i,:])
        dist = np.append(dist,[temp,i+1])
            #j = j + 1
        i = i + 1

    dist.shape=[-1,2]
    #dist = np.sort(dist,axis=0) 
    return dist

data = np.array([0.397658,0.264509,0.211837,0.486311])
weight = np.array([ 0.1875, 0.25, 0.25 , 0.3125])
data = data * weight

print calculate_deviation(data, average)